<!-- Soution found on StackOverflow - original source unknown -->

function maskInput() {
        var key_code = window.event.keyCode;
        var oElement = window.event.srcElement;
        if (!window.event.shiftKey && !window.event.ctrlKey && !window.event.altKey) {
                if ((key_code > 47 && key_code < 58) ||
                          (key_code > 95 && key_code < 106)) {
                                if (key_code > 95) 
                                        key_code -= (95-47);
                           oElement.value = oElement.value;
                } else if(key_code == 8) {
                        oElement.value = oElement.value;
                } else if(key_code != 9) {
                        event.returnValue = false;
                }    
        }
    }